<template>
  <el-input placeholder="请输入你想搜索的商品" v-model="searchData" clearable>
    <template #append>
      <el-button :icon="Search" @click="commitSearch" />
    </template>
  </el-input>
</template>

<script>
import {Search} from "@element-plus/icons-vue";
import {getCurrentInstance} from "vue";
import router from "@/router";

export default {
  name: "SearchBar",
  data () {
    return {
      searchData: "",
    }
  },
  methods: {
    commitSearch() {
      router.push({
        name: 'FarmCropsList',
        query: {
          searchData: this.searchData,
        }
      })
    },
  },
  setup() {
    const { appContext : { config: { globalProperties } } } = getCurrentInstance();
    const staticResourcesUrl = globalProperties.$staticResourcesUrl;
    return{
      staticResourcesUrl,
      Search,
    }
  }
}
</script>

<style scoped>

</style>